<?php
$type = $_GET['type'] ?? '';
$pid = $_GET['pid'] ?? '';
if (!$pid) { echo 'no pid'; exit; }
$statFile = 'data/stat_' . $pid . '.json';
$stat = file_exists($statFile) ? json_decode(file_get_contents($statFile), true) : ['visit'=>0,'download'=>0];
if ($type === 'download') {
    $stat['download']++;
    file_put_contents($statFile, json_encode($stat, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT));
    echo 'ok';
    exit;
}
echo 'no action'; 